﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Blogs01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
        public static Dictionary<string, string> user = new Dictionary<string, string>();
        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var sql = string.Format("select * from Users where Username='{0}' and Password='{1}'", uid, pwd);
            var xx = DbHelper.GetDataTable(sql);

            if (string.IsNullOrEmpty(uid))
            {
                MessageBox.Show("用户名不能为空！");
                return;
            }
            else if (string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("密码不能为空！");
                return;
            }
            else if (!textBox2.Text.Equals(textBox3.Text))
            {
                MessageBox.Show("两次输入的密码不一致！");
                return;
            }
            if (xx.Rows.Count == 1)
            {
                DialogResult dr = MessageBox.Show("登陆成功", "登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MainForm mainform = new MainForm();
                this.Hide();
                mainform.Show();
            }
            else
            {
                DialogResult ds = MessageBox.Show("登陆失败,请查看用户名或密码是否输入正确", "退出", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {
         
        }

     
        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            this.Hide();
            form2.Show();
        }
    }
}
